#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 1e4 + 10, INF = 0x3f3f3f3f;
int dis[N];
bool st[N];
int mp[N][N];
int f[N];
int n, m;
int Prim(int x)
{
	memset(dis, 0x3f, sizeof(dis));
	dis[x] = 0;
	int res = 0;
	for (int i = 0; i < n; i++) {
		int t = -1;
		for (int j = 1; j <= n; j++) {
			if (!st[j] && (t == -1 || dis[t] > dis[j])) {
				t=j;
			}
		}
		if (i && dis[t] == INF) {
			return -1;
		}
		if (i) {
			res += dis[t];
		}
		st[t] = 1;
		for (int j = 1; j <= n; j++) {
			dis[j] = min(dis[j], mp[t][j]);
		}
	}
	return res;
}

int find(int x)
{
	if (x != f[x]) {
		f[x] = find(f[x]);
	}
	return f[x];
}
struct Edge
{
	int a, b, w;
}edge[N];
int Kruskal(int x)
{
	sort(edge, edge + m);
	for (int i = 1; i <= n; i++) {
		f[i] = i;
	}
	int res = 0;
	for (int i = 1; i <= m; i++) {
		int a = edge[i].a;
		int b = edge[i].b;
		int w = edge[i].w;
		int pa = find(a);
		int pb = find(b);
		if (pa != pb) {
			f[pa] = pb;
			res += w;
		}
	}
}
int main()
{
	
	return 0;
}